package io.github.heollhai.common.config.security.utils;


import io.github.heollhai.common.entity.security.dto.UserByRoleDto;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Author: lmf
 * @Create: 2024/8/13 15:31
 * Description:
 */
public class SecurityUtils {
    /**
     * 获取 线程池中的用户信息
     */
    public static UserByRoleDto getUserByRoleDto() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(principal instanceof UserByRoleDto userByRoleDto){
            return userByRoleDto;
        }
        return null;
    }
}
